<?php
include('../conf.php');
$user = $_REQUEST['user'];
$sql = "select user_id, username, password, tb_companies.comp_id as comp_id, tb_companies.name as comp_name from tb_user inner join tb_companies on tb_user.comp_id=tb_companies.comp_id where username=?";
$conn->SetFetchMode(ADODB_FETCH_ASSOC);
$rs = $conn->Execute($sql, array($user));
$data = $rs->GetRows();

$sql = "select ver_id, ver_name from tb_data_version where comp_id=? order by ver_id desc limit 1";
$rs = $conn->Execute($sql, array($data[0]['comp_id']));
$dtVersion = $rs->GetRows();
//print_r($data);
//echo json_encode($data);
$arrData = array (
	"username" => $data[0]['username'],
	"password" => $data[0]['password'],
	"comp_id" => $data[0]['comp_id'],
	"user_id" => $data[0]['user_id'],
	"comp_name" => $data[0]['comp_name'],
	"last_ver" => @$dtVersion[0]['ver_id']
);
echo json_encode($arrData);
?>